package www.openteam.com.presenter.policy;

import java.util.HashMap;
import java.util.List;

import www.openteam.com.base.BasePresenter;
import www.openteam.com.bean.ApprovalStatu;
import www.openteam.com.bean.PayableApproval;
import www.openteam.com.contract.policy.PayableApprovalContract;
import www.openteam.com.model.policy.PayableApprovalModel;
import www.openteam.com.mvp.IModel;
import www.openteam.com.ui.policy.PayableApprovalFragment;

/**
 * Created by hyd on 2017/1/15.
 */

public class PayableApprovalPresenter extends BasePresenter<PayableApprovalFragment>
    implements PayableApprovalContract.PayableApprovalPresenter {

    @Override
    public HashMap<String, IModel> getiModelMap() {
        return loadModelMap(new PayableApprovalModel());
    }

    @Override
    public HashMap<String, IModel> loadModelMap(IModel... models) {
        HashMap<String ,IModel> hashMap = new HashMap<>();
        hashMap.put("queryPayableApproval",models[0]);

        return hashMap;
    }

    @Override
    public void queryPayableApproval(String vendno, long startTime, long endTime,int orderStatus,
                                     String stype, String moreCom, int PageSize) {
        ((PayableApprovalModel)
                getiModelMap().get("queryPayableApproval"))
                .queryPayableApproval(vendno, startTime, endTime,orderStatus,stype,moreCom, PageSize,
                        new PayableApprovalModel.PayableApprovalOnListener(){
                            @Override
                            public void queryPASuccess(List<PayableApproval.DataEntity> payableApproval) {
                                getIView().queryPASuccess(payableApproval);
                            }

                            @Override
                            public void queryPAFail(String failMsg) {
                                getIView().queryPAFail(failMsg);
                            }
                        });
    }

    @Override
    public void unapprovalStatu(int id) {
        ( (PayableApprovalModel) getiModelMap().get("queryPayableApproval"))
                .unapprovalStatu(id, new PayableApprovalModel.PayableOrderUOnListener() {
                    @Override
                    public void unApprovalPASuccess(ApprovalStatu aprovalStatu) {

                        getIView().unApprovalPASuccess(aprovalStatu);

                    }

                    @Override
                    public void unApprovalPAFail(String failMsg) {
                        getIView().unApprovalPAFail(failMsg);
                    }
                });
    }

    @Override
    public void approvalStatu(int id) {
        ( (PayableApprovalModel) getiModelMap().get("queryPayableApproval"))
                .approvalStatu(id, new PayableApprovalModel.PayableOrderAOnListener() {
                    @Override
                    public void approvalPASuccess(ApprovalStatu aprovalStatu) {
                        getIView().approvalPASuccess(aprovalStatu);
                    }
                    @Override
                    public void approvalPAFail(String failMsg) {
                        getIView().approvalPAFail(failMsg);
                    }
                });
    }
}
